package com.example.wanted.service;

import com.example.wanted.model.Comment;
import com.example.wanted.repository.CommentRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

@Service
public class CommentService {
    final CommentRepository commentRepository;

    @Autowired
    public CommentService(@Qualifier("comment") CommentRepository commentRepository) {
        this.commentRepository = commentRepository;
    }

    public void save(Comment comment){
        commentRepository.save(comment);
    }

    public Comment[] findByUser(String user_id) {
        return commentRepository.findByUser(user_id);
    }

    public Comment[] findByQuestion(Long question_id) {
        return commentRepository.findByQuestion(question_id);
    }

    public Long findQuestionByUser(String user_id) {
        return commentRepository.findQuestionByUser(user_id);
    }

    public String findUserByQuestion(Long question_id) {
        return commentRepository.findUserByQuestion(question_id);
    }
}
